/*
 * echarts基于样式统一类
 *
 * line  折线图
 * lineD 面积图
 * lineZ 折线图带缩放
 * pie   饼状图
 * pieR  圆环
 * bar   柱状图
 * map   地图
 * sankey 桑基图
 * barMixPie  柱状，饼状图混搭
 * */
function fontSize(res){

    let docEl = document.documentElement,

        clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;

    if (!clientWidth) return;

    let fontSize = 100 * (clientWidth / 1920);

    return res*fontSize;



}
var MainChart = {

    /**
     * 默认折线图
     */
    line: function (lineDate, xValue, lineName, color) {
        return {
            color: color,
            grid: {
                // show:true,
                left: "10%",
                // top: "40",
                width: "100%",
                bottom: '10%',
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: xValue,
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: "#1f2026",
                        type: 'dashed'
                    }
                },
                axisLabel: {
                    fontSize: fontSize(0.12),
                }
            },
            yAxis:  {
                type:'value',
                show: true,
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: "#1f2026",
                    }
                },
                axisLabel: {
                    fontSize: fontSize(0.12),
                }
            },
            tooltip: {
                trigger: 'axis',
                backgroundColor: "#fff",
                borderColor: "#e1e4e8",
                borderWidth: 1,
                padding: [5, 10],
                textStyle: {
                    color: 'rgba(0,0,0,0.45)',
                },
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: ''        // 默认为直线，可选为：'line' | 'shadow'
                },
            },
            legend: {
                data: lineName,
                top: '10',
                left: '15',
                icon: 'circle',
                itemGap: 20, // 图例之间的间距
                itemWidth: 6,
                itemHeight: 6,
                textStyle: {
                    color: '#fff',
                    fontSize: fontSize(0.12),
                },
            },
            series: lineDate
        };
    },


    /**
     * 默认折线堆叠图
     * */
    lineD: function (echart_data, item) {

        //调色盘颜色列表,依次使用
        var color = ['#008eff', '#00f4f6'];

        //Y轴是否带单位
        var formatter = null;
        //面积渐变
        var areaStyle = {};
        //图例位置
        var legend_show = true;
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //是否显示最大最小平均值
        var _series_mark = true;
        //grid距离
        var grid_top = 30;
        //分隔线
        var splitNumber = 4;

        var _str = '';
        if (typeof(item) !== "undefined") {
            //单位
            if (item.formatter) {
                formatter = '{value} ' + item.formatter;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.areaStyle) {
                areaStyle = item.areaStyle;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }

            if (typeof(item._series_mark) != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.grid_top) {
                grid_top = item.grid_top;
            }
            if (typeof(item.legend_show) != "undefined") {
                legend_show = item.legend_show;
            }
            if (item.splitNumber) {
                splitNumber = item.splitNumber;
            }
        }
        var _series = [];
        var max = [];
        for (var j = 0; j < echart_data.data.length; j++) {
            var data = echart_data.data[j];
            max.push(Math.max.apply(null, data));
        }
        var _max = Math.max.apply(null, max);
        if (_max > 10000) {
            formatter = '{value}W';
        }
        if (_max > 1000 && _max < 10000) {
            formatter = '{value}K';
        }
        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            //数字处理
            var _data = echart_data.data[i];
            if (formatter == '{value}K') {
                var _data2 = [];
                for (var n = 0; n < _data.length; n++) {
                    var num2 = Number(_data[n]);
                    _data2.push((num2 / 1000).toFixed(1));
                }
                echart_data.data[i] = _data2;
            }

            if (formatter == '{value}W') {
                var _data3 = [];
                for (var nn = 0; nn < _data.length; nn++) {
                    var num22 = Number(_data[nn]);
                    _data3.push((num22 / 10000).toFixed(1));
                }
                echart_data.data[i] = _data3;
            }
            _series[i].data = echart_data.data[i];
            _series[i].type = "line";
            _series[i].stack = '<?php echo nn_lang("echarts_total");?>';
            _series[i].areaStyle = {};
            _series[i].areaStyle.normal = {};
            _series[i].smooth = true;
            _series[i].symbol = 'none';
            _series[i].areaStyle = areaStyle;

            //最大值，最小值
            if (_series_mark) {
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
                _series[i].markPoint.symbolSize = 46;
                _series[i].markPoint.label = {};
                _series[i].markPoint.label.normal = {};
                _series[i].markPoint.label.normal.textStyle = {};
                _series[i].markPoint.label.normal.textStyle.fontSize = 8;
                _series[i].markPoint.label.normal.textStyle.fontFamily = 'Arial,SimHei,黑体';
            }
        }

        var option = {

            title: {
                text: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    var len = params.length;
                    if (typeof len != "undefined") {
                        var str = params[0].name + '<br />';
                        for (var i = 0; i < params.length; i++) {
                            str += params[i].seriesName + ' : ' + params[i].data + _str + '<br />';
                        }
                        return str;
                    } else {
                        var str2 = params.name + '<br />';
                        str2 += params.seriesName + ' : ' + params.value + _str + '<br />';
                        return str2;
                    }
                }
            },
            legend: {
                show: legend_show,
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体'
                },
                x: legend_x,
                padding: legend_padding
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            grid: {
                left: '6%',
                right: '8%',
                bottom: '3%',
                containLabel: true,
                top: grid_top
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: echart_data.spot,
                axisLine: {
                    show: false,
                    lineStyle: {
                        color: '#43a0ff'
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: ['rgba(0,140,255,0.2)']
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#FFF',
                        align: 'center',
                        fontFamily: 'Arial,SimHei,黑体',
                        fontSize: 15
                    }
                }
            },
            yAxis: {
                type: 'value',
                axisLabel: {
                    formatter: formatter,
                    textStyle: {
                        color: '#FFF',
                        align: 'right',
                        fontFamily: 'Arial,SimHei,黑体',
                        fontSize: 15
                    }
                },
                splitLine: {
                    lineStyle: {
                        color: ['rgba(0,140,255,0.1)']
                    }
                },
                axisLine: {
                    show: false,
                    lineStyle: {
                        color: '#43a0ff'
                    }
                },
                axisTick: {
                    show: false
                },
                splitNumber: splitNumber
            },
            series: _series
        };

        return option;
    },

    /**
     * 默认饼状图
     * */
    pie: function (echart_data, item) {

        var _spot = echart_data.spot;
        var _series = {};
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var radius = "55%";

        if (typeof(item) !== "undefined") {

            if (item.color) {
                color = item.color;
            }
            if (item.radius) {
                radius = item.radius;
            }
            if(item.roseType)
            {
                _series.roseType = item.roseType;
            }

        }

        var _data = echart_data.data[0] || ['0']; // 默认取第一组val数据
        var _desc = echart_data.desc[0] || [];


        _series.name = _desc;
        _series.data = [];
        for (var i = 0; i < _data.length; i++) {
            _series.data[i] = {};
            _series.data[i].name = _spot[i];
            _series.data[i].value = _data[i];
        }
        _series.type = "pie";
        // _series.clockwise =true;
        _series.radius = radius;
        _series.conter = ['50%', '60%'];
        _series.labelLine = {
            normal: {
                show: false
            }
        };
        _series.label = {
            normal:{
                formatter: '{c} ',
            },
            emphasis: {
                show: true,
                textStyle: {
                    fontSize: '20',
                    fontWeight: 'bold'
                }
            }
        };

        var option = {
            title: {
                text: '',
                subtext: '',
                x: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: "{b} <br/>{a} : {c} ({d}%)"
            },
            legend: {
                show:true,
                orient: 'vertical',
                // left: 'right',
                right:'5%',
                data: _spot
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    mark: {show: true},
                    dataView: {show: true, readOnly: false}
                }
            },
            calculable: true,
            series: _series
        };

        return option;
    },

    /**
     * 默认圆环
     * */
    pieR: function (echart_data, item) {

        var _data = echart_data.data[0] || ['0']; // 默认取第一组val数据
        var _spot = echart_data.spot;
        var _desc = echart_data.desc[0] || [];

        var _series = {};
        _series.name = _desc;
        _series.data = [];
        for (var i = 0; i < _data.length; i++) {
            _series.data[i] = {};
            _series.data[i].name = _spot[i];
            _series.data[i].value = _data[i];
        }
        _series.type = "pie";
        _series.radius = ['50%', '70%'];
        _series.conter = ['50%', '60%'];

        var option = {
            title: {
                text: '',
                x: 'center',
                y: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: _spot
            },
            toolbox: {
                show: false,
                feature: {
                    mark: {show: true},
                    dataView: {show: true, readOnly: false}
                }
            },
            calculable: true,
            series: _series
        };

        return option;
    },


    /**
     * 组合饼状图
     * */
    pieZ: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = ['#0064ff', '#008eff', '#50beff', '#ca5cea', '#715fd0', '#552ae2', '#510482', '#1907ae'];
        var option = {};
        var map_data = [];

        if (typeof(item) != "undefined") {
            if (typeof item.color != "undefined") {
                color = item.color;
            }
        }
        for (var i = 0; i < echart_data.desc.length; i++) {
            if (echart_data.desc[i] == item.desc) {
                var _data = echart_data.data[i] || [];
                var spot_name = echart_data.spot;
                for (var j = 0; j < _data.length; j++) {
                    map_data[j] = {};
                    map_data[j].name = spot_name[j];
                    map_data[j].value = _data[j];
                }
            }
        }

        option = {
            color: color,
            series: [
                {
                    name: 'categoryA',
                    type: 'pie',
                    selectedMode: 'single',
                    radius: [0, '60%'],
                    label: {
                        normal: {
                            position: 'outer',
                            formatter: '{d}%',
                            textStyle: {
                                fontFamily: 'Arial,SimHei,黑体',
                                fontSize: 15,
                                color: '#008eff'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: true,
                            lineStyle: {
                                color: '#070482'
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            borderWidth: 0
                        }
                    },
                    data: map_data
                },
                {
                    name: 'categoryB',
                    type: 'pie',
                    label: {
                        normal: {
                            show: false
                        }
                    },
                    radius: ['70%', '71%'],
                    data: [{
                        'name': '假动作',
                        'value': 100
                    }]
                }
            ]
        };

        return option;
    },


    /**
     * 扇形饼图
     * */
    pieP: function (item,seriesData) {
        //调色盘颜色列表,依次使用
        var color = ['#be070d', '#d70e1f','#1382e3', '#ff9900', '#50beff', '#ca5cea', '#715fd0', '#552ae2'];
        // var color = ['#f17d4f','#d6ea2c','#8ce952','#d92876','#9939ec','#38e3cd'];
        var option;
        if (typeof(item) != "undefined") {
            if (typeof item.color != "undefined") {
                color = item.color;
            }
        }
        var listData = seriesData || [];
        option = {
            color: color,
            grid: {
                top: "30",
            },
            series: [
                {
                    name: '',
                    type: 'pie',
                    radius: '65%',
                    center: ['50%', '50%'],
                    // data: listData.sort(function (a, b) { return a.value - b.value; }),
                    data: listData.sort(function (a, b) { return a.value - b.value; }),
                    roseType: 'radius',
                    itemStyle: {
                        normal : {
                            label : {
                                formatter: '{b|{b}}{abg|}\n  {per|{d}%}  ',
                                rich: {
                                    b: {
                                        lineHeight: 12,
                                        align: 'left',
                                        fontSize: fontSize(0.12),
                                        padding:[0,7],
                                        color: '#fff'
                                    },
                                    per: {
                                        color: '#40ffff',
                                        padding: [2, 4],
                                        fontSize: fontSize(0.15),
                                        fontFamily: 'electronicFont'
                                    }
                                }
                            },
                            labelLine: {
                                lineStyle: {
                                    color: '#40ffff'
                                },
                                smooth: 0.2,
                                length: 10,
                                length2: 20
                            },
                        },
                        // color: '#40ffff',
                        // shadowBlur: 200,
                        // shadowColor: 'rgba(0, 0, 0, 0.5)'
                    },

                    animationType: 'scale',
                    animationEasing: 'elasticOut',
                    animationDelay: function (idx) {
                        return Math.random() * 300;
                    }
                },
            ]
        };

        return option;
    },

    /**
     * 直播分析圆环
     * */
    pieR_live: function (echart_data, item) {

        var color = ['#008eff', '#50beff', '#ca5cea', '#715fd0', '#31ffe9', '#a2ff00'];
        var _data = echart_data.data[0] || ['0']; // 默认取第一组val数据
        var _spot = echart_data.spot;
        var _desc = echart_data.desc[0] || [];

        var _series = {};
        _series.name = _desc;
        _series.data = [];
        for (var i = 0; i < _data.length; i++) {
            _series.data[i] = {};
            _series.data[i].name = _spot[i];
            _series.data[i].value = _data[i];
        }

        var option = {
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: '13%',
                data: _spot,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体',
                    fontSize: 15
                },
                x: 'left',
                itemWidth: 22,
                itemHeight: 11
            },
            color: color,
            series: [
                {
                    name: _desc,
                    type: 'pie',
                    radius: ["50%", "88%"],
                    center: ['65%', '50%'],
                    avoidLabelOverlap: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data: _series.data
                }
            ]
        };

        return option;
    },

    /**
     * 水平柱状图
     * */
    barH: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = item.color;
        var tooltip_fmt = false;
        var itemStyle = {};

        var spot = echart_data.spot;
        var formatterY = null, formatterX = null;
        var grid_left = '2%';
        var splitNumber = 3;

        //是否显示最大最小平均值
        var _series_mark = true;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }
            if (item.splitNumber) {
                splitNumber = item.splitNumber;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }
            //图例位置
            if (typeof item.legend_x != "undefined") {
                legend_x = item.legend_x;
            }
            if (typeof item.series_mark != "undefined") {
                _series_mark = item.series_mark;
            }
            if (typeof item.grid_left != "undefined") {
                grid_left = item.grid_left;
            }
            if (typeof item.color != "undefined") {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
        }


        var _series = [];
        //根据最大值获取单位
        var max = [];
        for (var j = 0; j < echart_data.data.length; j++) {
            var data = echart_data.data[j];
            max.push(Math.max.apply(null, data));
        }


        var _max = Math.max.apply(null, max);
        if (_max > 10000) {
            formatterX = '{value}W';
        }
        if (_max > 1000 && _max < 10000) {
            formatterX = '{value}K';
        }

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];

            //数字处理
            var _data = echart_data.data[i];
            if (formatterX == '{value}K') {
                var _data2 = [];
                for (var n = 0; n < _data.length; n++) {
                    var num2 = Number(_data[n]);
                    _data2.push((num2 / 1000).toFixed(1));
                }
                echart_data.data[i] = _data2;
            }

            if (formatterX == '{value}W') {
                var _data3 = [];
                for (var nn = 0; nn < _data.length; nn++) {
                    var num22 = Number(_data[nn]);
                    _data3.push((num22 / 10000).toFixed(1));
                }
                echart_data.data[i] = _data3;
            }

            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = "12";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
            _series[i].itemStyle = itemStyle;

            // if (_series_mark) {
            //     //最大值，最小值
            //     _series[i].markPoint.data = [];
            //     _series[i].markPoint.data[0] = {};
            //     _series[i].markPoint.data[0].type = "max";
            //     _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
            //     _series[i].markPoint.data[1] = {};
            //     _series[i].markPoint.data[1].type = "min";
            //     _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
            //     //平均线
            //     _series[i].markLine = {};
            //     _series[i].markLine.data = [];
            //     _series[i].markLine.data[0] = {};
            //     _series[i].markLine.data[0].type = "average";
            //     _series[i].markLine.data[0].name = '<?php echo nn_lang("echarts_average");?>';
            // }

        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体',
                    fontSize:'14'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            calculable: true,
            grid: {
                left: grid_left,
                right: '8%',
                bottom: '3%',
                // containLabel: true,
                top: 30,
                backgroundColor:'transparent'
            },
            xAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            color: '#FFF',
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitNumber: splitNumber
                }
            ],
            yAxis: [
                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        // formatter: formatterY,
                        formatter:  function (value) {
                            var regex = /^[a-zA-Z0-9_]+$/;
                            if(value)
                            {
                                if(regex.test(value))
                                {
                                    if(value.length>10)
                                    {
                                        // value = value.substr(0,15)+"\n"+value.substring(15,30);
                                        value = value.substr(0,10)+'...';
                                    }
                                }else{
                                    if(value.length>8)
                                    {
                                        // value = value.substr(0,8)+"\n"+value.substring(8,15);
                                        value = value.substr(0,6)+'...';
                                    }
                                }
                            }
                            return value;
                        },
                        textStyle: {
                            color: '#FFF',
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 46
                    }
                }
            ],
            series: _series,
            // animationEasing: 'elasticOut',
            animationEasingUpdate:'cubicout'
        };

        return option;
    },

    /**
     * 柱状图
     * */
    bar: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = ['#008eff', '#00f4f6'];
        var tooltip_fmt = false;
        var grid_left ='6%';
        var spot = echart_data.spot;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //Y轴是否带单位
        var formatterY = null, formatterX = null;
        var itemStyle = {};
        var barMaxWidth = "12";

        //是否显示最大最小平均值
        var _series_mark = true;

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }

            if (typeof item.grid_left != "undefined") {
                grid_left = item.grid_left;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }

            if (typeof item._series_mark != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
            if (item.barMaxWidth) {
                barMaxWidth = item.barMaxWidth;
            }
        }

        var _series = [];
        //根据最大值获取单位
        var max = [];
        for (var j = 0; j < echart_data.data.length; j++) {
            var data = echart_data.data[j];
            max.push(Math.max.apply(null, data));
        }
        var _max = Math.max.apply(null, max);
        if (_max > 10000) {
            formatterY = '{value}W';
        }
        if (_max > 1000 && _max < 10000) {
            formatterY = '{value}K';
        }

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            //数字处理
            var _data = echart_data.data[i];
            if (formatterY == '{value}K') {
                var _data2 = [];
                for (var n = 0; n < _data.length; n++) {
                    var num2 = Number(_data[n]);
                    _data2.push((num2 / 1000).toFixed(1));
                }
                echart_data.data[i] = _data2;
            }

            if (formatterY == '{value}W') {
                var _data3 = [];
                for (var nn = 0; nn < _data.length; nn++) {
                    var num22 = Number(_data[nn]);
                    _data3.push((num22 / 10000).toFixed(1));
                }
                echart_data.data[i] = _data3;
            }

            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = barMaxWidth;
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
            _series[i].itemStyle = itemStyle;

            // //最大值，最小值
            // if (_series_mark) {
            //     _series[i].markPoint = {};
            //     _series[i].markPoint.data = [];
            //     _series[i].markPoint.data[0] = {};
            //     _series[i].markPoint.data[0].type = "max";
            //     _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
            //     _series[i].markPoint.data[1] = {};
            //     _series[i].markPoint.data[1].type = "min";
            //     _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
            //     //平均线
            //     _series[i].markLine = {};
            //     _series[i].markLine.data = [];
            //     _series[i].markLine.data[0] = {};
            //     _series[i].markLine.data[0].type = "average";
            //     _series[i].markLine.data[0].name = '<?php echo nn_lang("echarts_average");?>';
            // }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体',
                    fontSize:'14'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            calculable: true,
            grid: {
                left: grid_left,
                right: '8%',
                bottom: '3%',
                containLabel: true,
                top: 30
            },
            xAxis: [

                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            color: '#FFF',
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: formatterY,
                        textStyle: {
                            color: '#FFF',
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 10
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    }
                }
            ],
            series: _series,
            // animationEasing: 'elasticOut'
            animationEasingUpdate:'cubicout'
        };

        return option;
    },


    /**
     * 柱状图
     * */
    bar2: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = ['#008eff', '#00f4f6'];
        var tooltip_fmt = false;

        var spot = echart_data.spot;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //Y轴是否带单位
        var formatterY = null, formatterX = null;
        var itemStyle = {};
        var barMaxWidth = "12";

        //是否显示最大最小平均值
        var _series_mark = true;

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }

            if (typeof item._series_mark != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
            if (item.barMaxWidth) {
                barMaxWidth = item.barMaxWidth;
            }
        }

        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            //数字处理
            var _data = echart_data.data[i];


            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = barMaxWidth;
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
            _series[i].itemStyle = itemStyle;

            //最大值，最小值
            if (_series_mark) {
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
                //平均线
                _series[i].markLine = {};
                _series[i].markLine.data = [];
                _series[i].markLine.data[0] = {};
                _series[i].markLine.data[0].type = "average";
                _series[i].markLine.data[0].name = '<?php echo nn_lang("echarts_average");?>';
            }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体',
                    fontSize:'14'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            calculable: true,
            grid: {
                left: '6%',
                right: '8%',
                bottom: '3%',
                containLabel: true,
                top: 30
            },
            xAxis: [

                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value} %',
                        textStyle: {
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 10
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    }
                }
            ],
            series: _series,
            animationEasing: 'elasticOut'
        };

        return option;
    },

    /**
     * 柱状图
     * */
    barE: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = ['#008eff', '#00f4f6'];
        var tooltip_fmt = false;

        var spot = echart_data.spot;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //Y轴是否带单位
        var formatterY = null, formatterX = null;
        var itemStyle = {};
        var barMaxWidth = "12";

        //是否显示最大最小平均值
        var _series_mark = true;

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }

            if (typeof item._series_mark != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
            if (item.barMaxWidth) {
                barMaxWidth = item.barMaxWidth;
            }
        }

        var _series = [];
        //根据最大值获取单位
        var max = [];
        for (var j = 0; j < echart_data.data.length; j++) {
            var data = echart_data.data[j];
            max.push(Math.max.apply(null, data));
        }
        var _max = Math.max.apply(null, max);
        if (_max > 10000) {
            formatterY = '{value}W';
        }
        if (_max > 1000 && _max < 10000) {
            formatterY = '{value}K';
        }


        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            //数字处理
            var _data = echart_data.data[i];
            if (formatterY == '{value}K') {
                var _data2 = [];
                for (var n = 0; n < _data.length; n++) {
                    var num2 = Number(_data[n]);
                    _data2.push((num2 / 1000).toFixed(1));
                }
                echart_data.data[i] = _data2;
            }

            if (formatterY == '{value}W') {
                var _data3 = [];
                for (var nn = 0; nn < _data.length; nn++) {
                    var num22 = Number(_data[nn]);
                    _data3.push((num22 / 10000).toFixed(1));
                }
                echart_data.data[i] = _data3;
            }

            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = barMaxWidth;
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
            _series[i].itemStyle = itemStyle;

            //最大值，最小值
            if (_series_mark) {
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
                //平均线
                _series[i].markLine = {};
                _series[i].markLine.data = [];
                _series[i].markLine.data[0] = {};
                _series[i].markLine.data[0].type = "average";
                _series[i].markLine.data[0].name = '<?php echo nn_lang("echarts_average");?>';
            }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            calculable: true,
            grid: {
                left: '6%',
                right: '8%',
                bottom: '3%',
                containLabel: true,
                top: 30
            },
            xAxis: [

                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: formatterY,
                        textStyle: {
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 10
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    }
                }
            ],
            series: _series,
            animationEasing: 'elasticOut'
        };

        return option;
    },


    /**
     * 组成柱状图
     * */
    barZ: function (echart_data, item) {

        var _dataZoom = [];
        var yAxis_axisLabel = {};
        var xAxis_axisLabel = {};
        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                yAxis_axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].stack = "总量";
            _series[i].type = "bar";
            _series[i].barMaxWidth = "40";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };

            if (i === 0) {
                //如果是第一组辅助数据，做特殊处理
                _series[i].itemStyle = {};
                _series[i].itemStyle.normal = {};
                _series[i].itemStyle.normal.barBorderColor = "rgba(0,0,0,0)";
                _series[i].itemStyle.normal.color = "rgba(0,0,0,0)";
                _series[i].itemStyle.emphasis = {};
                _series[i].itemStyle.emphasis.barBorderColor = "rgba(0,0,0,0)";
                _series[i].itemStyle.emphasis.color = "rgba(0,0,0,0)";
            } else {
                _series[i].label = {};
                _series[i].label.normal = {};
                _series[i].label.normal.show = true;
                _series[i].label.normal.position = "inside";
            }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                },
                formatter: function (params) {
                    var tar = params[1];
                    return tar.name + ' : ' + tar.value;
                }
            },
            color: color,
            toolbox: {
                show: false
            },
            calculable: true,
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '15%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    splitLine: {show: false},
                    data: echart_data.spot
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            dataZoom: _dataZoom,
            series: _series,
            animationEasing: 'elasticOut',
            // animationType: 'scale',
            // animationEasing: 'elasticOut',
            // animationDelay: function (idx) {
            //     return Math.random() * 200;
            // }
        };
        return option;
    },

    /**
     * 默认柱状堆叠图
     * */

    barS: function (echart_data, item) {
        //调色盘颜色列表,依次使用
        var color = ['#008eff', '#00f4f6'];
        var tooltip_fmt = false;

        var spot = echart_data.spot;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //Y轴是否带单位
        var formatterY = null, formatterX = null;
        var itemStyle = {};
        var barMaxWidth = "12";

        //是否显示最大最小平均值
        var _series_mark = true;

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }

            if (typeof item._series_mark != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
            if (item.barMaxWidth) {
                barMaxWidth = item.barMaxWidth;
            }
        }

        var _series = [];
        //根据最大值获取单位
        var max = [];
        for (var j = 0; j < echart_data.data.length; j++) {
            var data = echart_data.data[j];
            max.push(Math.max.apply(null, data));
        }
        var _max = Math.max.apply(null, max);
        if (_max > 10000) {
            formatterY = '{value}W';
        }
        if (_max > 1000 && _max < 10000) {
            formatterY = '{value}K';
        }

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            //数字处理
            var _data = echart_data.data[i];
            if (formatterY == '{value}K') {
                var _data2 = [];
                for (var n = 0; n < _data.length; n++) {
                    var num2 = Number(_data[n]);
                    _data2.push((num2 / 1000).toFixed(1));
                }
                echart_data.data[i] = _data2;
            }

            if (formatterY == '{value}W') {
                var _data3 = [];
                for (var nn = 0; nn < _data.length; nn++) {
                    var num22 = Number(_data[nn]);
                    _data3.push((num22 / 10000).toFixed(1));
                }
                echart_data.data[i] = _data3;
            }
            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = barMaxWidth;
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
            _series[i].itemStyle = itemStyle;
            _series[i].stack = echart_data.desc[i][0];

            //最大值，最小值
            if (_series_mark) {
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '<?php echo nn_lang("echarts_max");?>';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '<?php echo nn_lang("echarts_min");?>';
                //平均线
                _series[i].markLine = {};
                _series[i].markLine.data = [];
                _series[i].markLine.data[0] = {};
                _series[i].markLine.data[0].type = "average";
                _series[i].markLine.data[0].name = '<?php echo nn_lang("echarts_average");?>';
            }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            toolbox: {
                show: false,
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']}
                }
            },
            calculable: true,
            grid: {
                left: '6%',
                right: '8%',
                bottom: '3%',
                containLabel: true,
                top: 30
            },
            xAxis: [

                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: formatterY,
                        textStyle: {
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 10
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    }
                }
            ],
            series: _series,
            animationEasing: 'elasticOut'
        };

        return option;
    },

    /**
     * 纵向柱状图
     */
    barVertical: function (rankList, type) {
        let dataX = [];
        let dataY = [];
        rankList.forEach(item => {
            dataX.push(item.name);
            dataY.push(item.value1||0);
        })
        let option = {
            grid: {
                left: 10,
                right: 30,
                bottom: 0,
                top: 0,
                containLabel: true
            },
            xAxis: {
                type: 'value',
                show: false,
                boundaryGap: [0, 0.01]
            },
            yAxis: {
                type: 'category',
                "axisLine":{       //y轴
                    "show":false
                },
                "axisTick":{       //y轴刻度线
                    "show":false
                },
                "splitLine": {     //网格线
                    "show": false
                },
                axisLabel :{
                    fontSize: fontSize(0.12),
                    color: '#ffffff',
                },
                data: dataX
            },
            series: [
                {
                    name: '2011年',
                    type: 'bar',
                    barCategoryGap:'50%',
                    label: {
                        show: true,
                        position: 'right', // 相对位置
                        color: '#ffffff',
                        formatter:function(params){ //标签内容
                            let res = type===1?params.value: params.value + '%'
                            return res
                        },
                    },
                    data: dataY
                },
            ]
        };
        for(var i = 0; i< option.series.length; i++){
            var style = [
                {
                    normal: {
                        barBorderRadius: [0, 20, 20, 0],
                        //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                        color: function (params) {
                            var colorList = [
                                ['#e97afb', '#09070d'],
                                ['#8db7fc', '#09070d'],
                                ['#42f1fd', '#09070d'],
                                ['#56e895', '#09070d'],
                                ['#fec955', '#09070d'],
                                ['#fd9c64', '#09070d'],
                                ['#e2299e', '#09070d'],
                                ['#5127e9', '#09070d'],
                                ['#297ce2', '#09070d'],
                                ['#ee2150', '#09070d'],
                            ];
                            var index = params.dataIndex;
                            if (params.dataIndex >= colorList.length) {
                                index = params.dataIndex - colorList.length;
                            }
                            return new echarts.graphic.LinearGradient(0, 0, 1, 0,
                                [{
                                    offset: 0,
                                    color: colorList[index][1]
                                },
                                    {
                                        offset: 1,
                                        color: colorList[index][0]
                                    }
                                ]);
                        }
                    },
                    emphasis: {
                        color: '#ee2150',
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0,0,0,5)'
                    }
                }
            ];
            option.series[i].itemStyle = style[i]; // series中每条数据都加的样式

        };
        return option
    },
    /**
     * 柱状图颜色渐变
     */
    barGradual: function (data,label) {
        let dataX = ['原发性醛固酮增多症', '皮质癌','嗜铬细胞瘤','无功能腺癌','库欣综合征','髓质脂肪癌','其他'];
        let delData = {}
        let seriesData = []
        let __data = data || []
        for (let key in data) {
            delData[label[key]] = __data[key]
        }
        dataX.forEach(item => {
            seriesData.push({
                value: delData[item] || 0,
            })
        })
        var option = {
            grid: {
                left: '3%',
                right: '4%',
                bottom: '10%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    show: false,
                    data: [],
                    axisTick: {
                        alignWithLabel: true
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: "#1f2026",
                        }
                    },
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: "#1f2026",
                        }
                    },
                    axisLabel: {
                        fontSize: fontSize(0.12),
                    }
                }
            ],
            tooltip: {
                trigger: 'axis',
                backgroundColor: "#fff",
                borderColor: "#e1e4e8",
                borderWidth: 1,
                padding: [5, 10],
                textStyle: {
                    color: 'rgba(0,0,0,0.45)',
                },
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
                },
            },
            legend: {
                data: ['原发性醛固酮增多症', '皮质癌','嗜铬细胞瘤','无功能腺癌','库欣综合征','髓质脂肪癌','其他'],
                top: '4',
                left: '15',
                icon: 'circle',
                itemGap: 15, // 图例之间的间距
                itemWidth: 6,
                itemHeight: 6,
                textStyle: {
                    color: '#fff',
                    fontSize: fontSize(0.12),
                },
            },
            color:['#e97afb','#8db7fc','#42f1fd','#56e895','#fec955','#fd9c64','#e93737'],
            series: [
                {name:'原发性醛固酮增多症'},
                {name:'皮质癌'},
                {name:'嗜铬细胞瘤'},
                {name:'无功能腺癌'},
                {name:'库欣综合征'},
                {name:'髓质脂肪癌'},
                {name:'其他'},
            ]
        };
        for(var i = 0; i< option.series.length; i++){
            var style = [
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#e97afb', '#09070d',],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#8db7fc', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#42f1fd', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#56e895', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#fec955', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#fd9c64', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                {normal: {
                    //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                    color: function (params) {
                        var colorList = [
                            ['#e22944', '#09070d'],
                        ];
                        var index = params.dataIndex;
                        if (params.dataIndex >= colorList.length) {
                            index = params.dataIndex - colorList.length;
                        }
                        return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                            [{
                                offset: 0,
                                color: colorList[index][0]
                            },
                                {
                                    offset: 1,
                                    color: colorList[index][1]
                                }
                            ]);
                    }
                }},
                ];
            option.series[i].type = 'bar'; //每条数据指定类型为'bar'
            option.series[i].itemStyle = style[i]; // series中每条数据都加的样式
            option.series[i].data = [seriesData[i]]; //series 中 data赋值
            // option.series[i].barCategoryGap = '40%';
            option.series[i].barGap= '45%';
            option.series[i].label = {
                    show: true,
                    position: 'top', // 相对位置
                    color: '#ffffff',
                    fontSize: fontSize(0.12),
            };
        };
        return option
    },

    /**
     * 默认地图
     * */
    map: function (echart_data, item) {

        echarts.registerMap(item.geoName, JSON.parse(item.geoJson));

        var _series = [];
        var _max = 100;
        var code = '<?php echo NN_MAP_CODE;?>';
        var option = {};

        for (var i = 0; i < echart_data.desc.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].type = "map";
            _series[i].mapType = item.geoName;
            _series[i].label = {};
            _series[i].label.emphasis = {};
            _series[i].label.emphasis.show = true;
            _series[i].itemStyle = {};
            _series[i].itemStyle.emphasis = {};
            _series[i].itemStyle.emphasis.areaColor = '#ffd373';

            _series[i].data = [];
            var _data = echart_data.data[i] || [];
            var spot_name = echart_data.spot;

            for (var j = 0; j < _data.length; j++) {
                _series[i].data[j] = {};
                _series[i].data[j].name = spot_name[j];
                _series[i].data[j].value = _data[j];
                if (_max < _data[j]) {
                    _max = Math.ceil(_data[j]);
                }
            }

            var _mm = _max % 100;
            if (_mm > 0) {
                _max = (_max - _mm) + 100;
            }
        }

        option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: echart_data.desc
            },
            toolbox: {
                show: false
            },
            visualMap: {
                min: 0,
                max: _max,
                left: 'left',
                top: 'bottom',
                // 文本，默认为数值文本
                text: ['<?php echo nn_lang("map_max");?>', '<?php echo nn_lang("map_min");?>'],
                calculable: true,
                inRange: {
                    color: ['#eebd54', '#f3516c']
                }
            },
            series: _series
        };

        return option;
    },

    /**
     * 组合地图
     * */
    mapZ: function (echart_data, map, item) {
        echarts.registerMap(map.geoName, map.geoJson);

        var _series = [];
        var _max = 100;
        var option = {};
        //地图颜色范围
        var range_color = ['#1361bc', '#59ffff'];
        //文字样式
        var geo_label_normal = {};
        //图形样式
        var geo_item_normal = {};
        //手柄文字样式
        var visual_text = {};
        //effectScatter数据
        var effectScatter = [];
        var effect_color = '#ffc400';
        //是否显示拖动组件
        var visual_show = true;
        //是否显示图例及图例位置
        var legend = {};
        var map_name = '';
        //地图与canvas左边距离
        var geo_left = '28%';
        var map_data = [];
        //新疆
        var geo_top = 'bottom';
        if (typeof(item) != "undefined") {
            if (item.range_color) {
                range_color = item.range_color;
            }
            if (item.effect_color) {
                effect_color = item.effect_color;
            }
            if (item.map_name) {
                map_name = item.map_name;
            }

            if (item.geo_left) {
                geo_left = item.geo_left;
            }
            if (typeof item.geo_label_normal != "undefined") {
                geo_label_normal = item.geo_label_normal;
            }
            if (typeof item.geo_item_normal != "undefined") {
                geo_item_normal = item.geo_item_normal;
            }
            if (typeof item.visual_text != "undefined") {
                visual_text = item.visual_text;
            }
            if (typeof item.effectScatter != "undefined") {
                effectScatter = item.effectScatter;
            }
            if (typeof item.visual_show != "undefined") {
                visual_show = item.visual_show;
            }
            if (typeof item.legend != "undefined") {
                legend = item.legend;
            }
            if (typeof item.grid_top != "undefined") {
                grid_top = item.grid_top;
            }
            if (typeof item.geo_top != "undefined") {
                geo_top = item.geo_top;
            }
        }
        for (var i = 0; i < echart_data.desc.length; i++) {
            if (echart_data.desc[i] == item.desc) {
                var _data = echart_data.data[i] || [];
                var spot_name = echart_data.spot;
                for (var j = 0; j < _data.length; j++) {
                    map_data[j] = {};
                    map_data[j].name = spot_name[j];
                    map_data[j].value = _data[j];
                    if (_max < _data[j]) {
                        _max = Math.ceil(_data[j]);
                    }
                }

                var _mm = _max % 100;
                if (_mm > 0) {
                    _max = (_max - _mm) + 100;
                }
            }
        }

        option = {
            legend: legend,
            visualMap: {
                show: visual_show,
                min: 0,
                max: _max,
                left: 'left',
                top: 'bottom',
                // 文本，默认为数值文本
                text: ['高', '低'],
                seriesIndex: [0],
                calculable: true,
                inRange: {
                    color: range_color
                },
                textStyle: visual_text
            },
            geo: {
                map: map.geoName,
                label: {
                    emphasis: {
                        show: false,
                        color: '#f4e925',
                        ellipsis: true,
                        fontSize: 22,
                        fontFamily: "微软雅黑,'Microsoft YaHei'",
                        textBorderColor:"#f4e925",
                        textBorderWidth:1
                    },
                    normal: {
                        show: false,
                        color: '#f4e925',
                        ellipsis: true,
                        fontSize: 15,
                        fontFamily: "微软雅黑,'Microsoft YaHei'"
                    }
                },
                itemStyle: {
                    normal: geo_item_normal,
                    emphasis:{
                        label:{show:true},
                        areaColor:'#a6f552',
                        borderColor: '#fff',
                        borderWidth: 1,
                        shadowColor: 'rgba(0, 0, 0, 1)',
                        shadowBlur: 30,
                        opacity: 0.70
                    }
                },
                silent: true,
                left: 'center',
                top: 'middle'
            },
            tooltip: {
                trigger: 'item',
                showDelay: 0,
                transitionDuration: 0.2,
                textStyle: {
                    align: 'right',
                    fontFamily: 'Arial,SimHei,黑体',
                    fontSize: 20,
                    height: 56
                },
                formatter: function (params) {
                    // get_region_info(params.name);
                    //if (params.data.value.length == 3) {
                    //    return params.name + "：" + STD.TOOL.toThousands(params.data.value[2]);
                    //} else {
                    //    return params.name + "：" + STD.TOOL.toThousands(params.data.value);
                    //}
                }
            },
            series: [
                {
                    name: 'B',
                    type: 'map',
                    geoIndex: 0,
                    data: effectScatter,
                    label: {
                        normal: {
                            formatter: '{b}',
                            position: 'right',
                            show: true
                        },
                        emphasis: {
                            show: false
                        }
                    },
                    itemStyle:{
                        normal:{label:{show:true}},
                        emphasis:{
                            label:{show:true},
                            areaColor:'#000'
                        }
                    }
                }
            ]
        };

        return option;
    },

    /**
     * 矩形树图
     * */
    treeMap: function (echart_data, item) {

        var option = {};
        var color = ['#0064ff', '#008eff', '#775cea', '#5c5fea', '#5c87ea', '#5cb3ea', '#5cdbea', '#5cea95', '#50beff', '#552ae2', '#3e6cd4', '#4090d0'];
        var map_data = [];

        for (var i = 0; i < echart_data.desc.length; i++) {
            var _data = echart_data.data[i] || [];
            var spot_name = echart_data.spot;
            for (var j = 0; j < _data.length; j++) {
                map_data[j] = {};
                map_data[j].name = spot_name[j];
                map_data[j].value = _data[j];
            }
        }

        option = {
            color: color,
            series: [{
                name: 'ALL',
                type: 'treemap',
                label: {
                    show: true,
                    formatter: "{b}",
                    normal: {
                        textStyle: {
                            ellipsis: true,
                            color: '#00ffff',
                            fontSize: 16,
                            fontFamily: "Arial,Adobe 黑体 Std R"
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        borderColor: 'rgba(0,0,0,0)',
                        borderWidth: 1
                    }
                },
                breadcrumb: {
                    show: false
                },
                data: map_data
            }]
        };

        return option;
    },


    /*
     * 桑基图
     * */
    sankey: function (echart_data, item) {

        var option = {
            title: {
                text: ''
            },
            tooltip: {
                trigger: 'item',
                triggerOn: 'mousemove',
                formatter: function (params) {
                    if (typeof params.data.source != "undefined" && typeof params.data.target != "undefined" && typeof params.data.value != "undefined") {
                        return params.data.source + " -- " + params.data.target + " <?php echo nn_lang('conversion_rate');?>：" + params.data.value + "%";
                    } else {
                        return params.data.id;
                    }

                }

            },

            color: ["#50beff", "#ca5cea", "#31ffe9", "#a2ff00", "#007fff"],
            series: [
                {
                    type: 'sankey',
                    nodeWidth: 5,//图中每个矩形节点的宽度。
                    top: '23%',
                    left: '8%',
                    right: '20%',
                    bottom: '10%',
                    layout: 'none',
                    data: echart_data.nodes,
                    links: echart_data.links,
                    itemStyle: {
                        normal: {
                            //color: ["#007fff"],
                            nodeWidth: 10,
                            borderWidth: 0,
                            borderColor: '#00b8f2',

                        }
                    },
                    label: {
                        normal: {
                            textStyle: {
                                color: "#00b8f2",
                                fontWeight: "bolder"
                            }
                        }
                    },
                    lineStyle: {
                        normal: {
                            color: '#007fff',
                            curveness: 0.5
                        }
                    }
                }
            ]
        };

        return option;
    },


    /**
     * 柱状图，饼状图混搭
     * */
    barMixPie: function (echart_data, item) {

        //调色盘颜色列表,依次使用
        var color = ['#ca5cea', '#007fff'];
        var tooltip_fmt = false;

        var spot = echart_data.spot;
        //图例位置
        var legend_x = 'right';
        var legend_padding = [0, 40, 0, 0];
        //Y轴是否带单位
        var formatterY = null, formatterX = null;
        var itemStyle = {};
        var barMaxWidth = "12";

        //是否显示最大最小平均值
        var _series_mark = true;

        if (typeof(item) !== "undefined") {
            if (item.formatterX) {
                formatterX = '{value} ' + item.formatterX;
            }
            if (item.formatterY) {
                formatterY = '{value} ' + item.formatterY;
            }

            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }

            if (typeof item._series_mark != "undefined") {
                _series_mark = item._series_mark;
            }
            if (item.legend_x) {
                legend_x = item.legend_x;
            }
            if (item.legend_padding) {
                legend_padding = item.legend_padding;
            }
            if (item.color) {
                color = item.color;
            }
            if (item.itemStyle) {
                itemStyle = item.itemStyle;
            }
            if (item.barMaxWidth) {
                barMaxWidth = item.barMaxWidth;
            }
        }

        var option = {
            title: {
                text: '',
                subtext: ''
            },
            tooltip: {
                show: true,
                //position:['50%','10%'],
                //borderColor: "#FFFFFF",
                //backgroundColor: "rgba(50,50,50,0.7)",
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow',        // 默认为直线，可选为：'line' | 'shadow'
                    shadowStyle: {
                        barBorderWidth: 1,
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowColor: 'rgba(0,0,0,0.5)',
                        opacity: 1
                    }
                },
                formatter: "{b} : {c}%"
            },
            legend: {
                show: false,
                data: echart_data.desc,
                textStyle: {
                    color: '#9bddff',
                    fontFamily: 'Arial,SimHei,黑体'
                },
                x: legend_x,
                padding: legend_padding,
                icon: 'rect',
                itemWidth: 22,
                itemHeight: 6
            },
            color: color,
            calculable: true,
            grid: {
                left: '2%',
                right: '5%',
                bottom: '3%',
                containLabel: true,
                top: 40
            },
            xAxis: [

                {
                    type: 'category',
                    data: spot,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.1)']
                        }
                    },
                    axisLabel: {
                        formatter: formatterX,
                        textStyle: {
                            align: 'center',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: formatterY,
                        textStyle: {
                            align: 'right',
                            fontFamily: 'Arial,SimHei,黑体',
                            fontSize: 15
                        },
                        margin: 10
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: ['rgba(0,140,255,0.2)']
                        }
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#43a0ff'
                        }
                    },
                    axisTick: {
                        show: false
                    }
                }
            ],
            series: [
                {
                    name: echart_data.desc[0],
                    type: 'bar',
                    barMaxWidth: "50",
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = ['#007fff'];
                                return colorList[params.dataIndex]
                            }
                        },
                        emphasis: {
                            barBorderWidth: 1,
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowOffsetY: 0,
                            shadowColor: 'rgba(0,0,0,0.5)'
                        }
                    },
                    data: echart_data.data[0],
                    markPoint: {
                        data: [
                            {type: 'max', name: '<?php echo nn_lang("echarts_max");?>'},
                            {type: 'min', name: '<?php echo nn_lang("echarts_min");?>'}
                        ]
                    }
                }
                ,
                {
                    center: ['78%', '25%'],
                    radius: '33%',
                    name: '播放转换率',
                    type: 'pie',
                    silent: true,
                    stillShowZeroSum: false,
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = ['#ca5cea', '#007fff'];
                                return colorList[params.dataIndex]
                            }
                        }
                    },
                    data: []
                }
            ]
        };
        return option;
    }
};


/*
 * 工具函数
 * */
var MainTool = {
    /*
     * 定时器
     * 固定凌晨几点点运行函数
     * */
    timeFixed: function (callback, hour) {
        var today = new Date();
        var now_time = today.getTime();
        var night_time = new Date(new Date().toLocaleDateString()).getTime() + (24 + hour) * 60 * 60 * 1000;
        var difference = night_time - now_time;
        setTimeout(function () {
            if (typeof callback == "function") {
                callback();
            }
        }, difference);
    },

    /*
     * 定时器
     * 每天执行函数
     * */
    timeCycle: function (callback, hour) {
        if (typeof hour == "undefined") {
            hour = 7;
        }
        MainTool.timeFixed(callback, hour);
        setInterval(function () {
            MainTool.timeFixed(callback, hour);
        }, 60 * 60 * 1000 * 24);
    },

    /*
     * 字符串匹配
     * 4个中文字符,8个英文字符
     * */
    strReg: function (arr, base) {
        var _base = base;
        if (typeof base == "undefined") {
            _base = 4;
        }
        var reg = /[\u4E00-\u9FA5]|[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]/;
        var spot = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] == null) {
                spot.push(arr[i]);
                continue;
            }
            if (reg.test(arr[i])) {
                spot.push(arr[i].substr(0, _base));
            } else {
                spot.push(arr[i].substr(0, _base * 2));
            }
        }
        return spot;
    },


    /*
     * 文字滚动
     * */
    marquee: function (className, children) {
        var parent_obj = document.getElementsByClassName(className);
        for (var i = 0; i < parent_obj.length; i++) {
            var child_obj = parent_obj[i].getElementsByClassName(children)[0];
            var child_width = child_obj.offsetWidth;
            var parent_width = parent_obj[i].offsetWidth;
            //是否已存在marquee
            var marquee_obj = $(child_obj).find("marquee");
            var len = marquee_obj.length;
            //替换innerHTML
            if (child_width > parent_width && len <= 0) {
                var text = child_obj.innerHTML;
                child_obj.innerHTML = '<marquee  direction="left" behavior="scroll" align="baseline" scrollamount="3">' + text + '</marquee>';
            } else if (child_width <= parent_width && len > 0) {
                child_obj.innerHTML = $(marquee_obj).text();
            }
        }
        $(window).resize(function(){
            setTimeout(function(){
                MainTool.marquee(className,children);
            },10);
        });
    }
};

//文字滚动
function marquee() {
    this.behavior = "scroll";//scroll:循环滚动  slide:只滚动一次就停止； alternate:来回交替进行滚动
    this.px = 3;//每次移动像素
    this.elements = null;//操作元素集，jquery对象
    this.obj = null;//当前操作对象,jquery
    this.text = "";//文本内容
    this.tlen = 8;//字符串超长限制，字节
}

marquee.prototype.init = function (element, tl) {

    var self = this;

    if (typeof element != "object") {
        console.log("调用对象错误");
        return;
    }

    if (!isNaN(parseInt(tl))) {
        this.tlen = tl;
    }

    self.elements = element;

    self.elements.mouseover(function () {
        self.mouseover($(this));
    });
    self.elements.mouseout(function () {
        self.mouseout($(this));
    });

}

marquee.prototype.mouseover = function (obj) {
    var self = this;
    self.obj = obj;
    self.text = $.trim(self.obj.text());
    if (self.text.replace(/[\u0391-\uFFE5]/g, "cc").length > self.tlen) {
        self.obj.html('<marquee  direction="left" behavior="' + self.behavior + '"  scrollamount="' + self.px + '" onmouseover="this.stop()" onmouseout="this.start()">' + self.text + '</marquee>');
    }
}

marquee.prototype.mouseout = function (obj) {
    var self = this;
    obj.text(self.text);
}
